package org.springblade.modules.feedback.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@AllArgsConstructor
@RequestMapping("blade-notice/client-notice")
@Api(value = "消息通知", tags = "消息通知接口")
public class ClientNoticeController {

	private final BladeRedis bladeRedis;
	public static  final String NOTICE_INFO_KEY="NOTICE_INFO_KEY";

	@GetMapping("/message")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "通知消息", notes = "")
	public R info() {
		return R.data(bladeRedis.get(NOTICE_INFO_KEY));
	}


	@GetMapping("/save")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "保存通知消息", notes = "")
	public R info(String message) {
		bladeRedis.set(NOTICE_INFO_KEY,message);
		return R.success("保存成功");
	}

}
